#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	if(b>=a) cout<<b-a<<endl;
	else 
	{
		ll ans = 0;
		while(a > b)
		{
	    	if(a%2==1) a = a+1,ans++;
			else a = a/2,ans++;
	   }
	   ans = (b-a) + ans;
	   cout<<ans<<endl;
	}
	return 0;
}
